package com.youshuit.designmodedemo.enumx;

// 支付类型枚举
public enum PayType {
    WECHAT("wechat", "微信支付"),
    ALIPAY("alipay", "支付宝支付"),
    CMB("cmb", "招商银行支付");

    private String code;
    private String name;

    PayType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据code获取枚举
     */
    public static PayType getByCode(String code) {
        for (PayType payType : values()) {
            if (payType.getCode().equals(code)) {
                return payType;
            }
        }
        return null;
    }
}
